/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package cn.ac.iie.di.File;

import java.io.File;
import java.io.FilenameFilter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.apache.log4j.Logger;

/**
 *
 * @author LXH
 */
public class FileTool {
    private static  Logger log = Logger.getLogger(FileTool.class.getName());
    public static List<String> getFile(String path){
        File file=new File(path);
        String[]sns=file.list(new FilenameFilter() {
            @Override
            public boolean accept(File dir, String name) {
                return name.endsWith(".sns");
            } 
        });
        String[]ok=file.list(new FilenameFilter() {
            @Override
            public boolean accept(File dir, String name) {
                return name.endsWith(".ok");
            }
        });
//        log.info(Arrays.asList(ok));
//        log.info(Arrays.asList(sns));
        List<String> snsfile=Arrays.asList(sns);
        List<String> okfile=new ArrayList(Arrays.asList(ok));
        for(int i=0;i<snsfile.size();i++){
            okfile.remove(snsfile.get(i).substring(0,snsfile.get(i).length()-4)+".ok");
        }
//        log.info(Arrays.asList(okfile));
        for(int i=0;i<okfile.size();i++){
            okfile.set(i,okfile.get(i).substring(0,okfile.get(i).length()-3));
        }
        return okfile;
    }
}  
    
